import request from '@/utils/request';

export type ArticleByIdType = {
  channel_id: number;
  timestamp: number;
};

/** 根据指定频道获取文章推荐Api */
export function GetArticleByIdApi(params: ArticleByIdType) {
  return request({
    url: '/v1_0/articles',
    params,
  });
}

/** 根据指定文章Id获取文章详情Api */
export function GetArticleDetailByIdApi(article_id: string) {
  return request({
    url: `/v1_0/articles/${article_id}`,
  });
}

/** 文章点赞Api */
export function ArticlelikingsApi(article_id: string) {
  return request({
    url: `/v1_0/article/likings`,
    method: 'post',
    data: { target: article_id },
  });
}

/** 文章取消点赞Api */
export function ArticleCancellikingsApi(article_id: string) {
  return request({
    url: `/v1_0/article/likings/${article_id}`,
    method: 'delete',
  });
}

/** 文章收藏Api */
export function ArticlecollectionsApi(article_id: string) {
  return request({
    url: `/v1_0/article/collections`,
    method: 'post',
    data: { target: article_id },
  });
}

/** 文章取消收藏Api */
export function ArticleCancelcollectionsApi(article_id: string) {
  return request({
    url: `/v1_0/article/collections/${article_id}`,
    method: 'delete',
  });
}

/** 关注Api */
export function followingsApi(article_id: string) {
  return request({
    url: `/v1_0/user/followings`,
    method: 'post',
    data: { target: article_id },
  });
}

/** 取消关注Api */
export function CancelfollowedApi(article_id: string) {
  return request({
    url: `/v1_0/user/followings/${article_id}`,
    method: 'delete',
  });
}
